var customer = {
	keyword:'',
	
    currentProductPageNo:0,
    
    currentOrderPageNo:0,
    
    currentOrderListOrderType:'desc',
    
    recommendProductsPerPageSize:8,
    
    getCurrentUserInfo:function(flag){
        $.ajax({
            type: "GET",
            url: config.baseURL + "account/userInfo.json",
            cache:false,
            dataType: "json",
            success: function(data){
                if(data.result == 'success'){
                	var account = data.account;
                	if(flag==0){
                		customer.showUserInfo(account);
                	}else{
                		customer.setUserInfoToUpdate(account);
                	}
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>获取个人信息失败！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    showUserInfo:function(account){
    	var accountType = "";
    	var manageUrl = "";
    	if(account.accountType==1){
            accountType = "买家";
            manageUrl = config.baseURL + "home";
    	}else if(account.accountType==2){
            accountType = "卖家";
            manageUrl = config.baseURL + "merchant/home";
    	}else{
            accountType = "客服";
            manageUrl = config.baseURL + "merchant/home";
    	}
    	$('#nickName').html(account.nickName);
        $('#userName').html(account.userName);
        $('#accountType').html(accountType);
        $('#lastLoginDateTime').html(new Date(account.lastLoginDate).pattern("yyyy-MM-dd HH:mm:ss"));
    	$('#lastLoginDate').html(new Date(account.lastLoginDate).pattern("yyyy-MM-dd"));
    	$('#manageUrl').attr("href",manageUrl);
    },
    setUserInfoToUpdate:function(account){
    	$('#id').val(account.id);
    	
    	if(account.telephone){
        	var tel = account.telephone;
        	var telArray = tel.split("-");
            $("#zoneNo").val(telArray[0]?telArray[0]:"");
            $("#telNo").val(telArray[1]?telArray[1]:"");
            $("#extensionNo").val(telArray[2]?telArray[2]:"");
            
            $("#tel").val(tel);
    	}
    	if(account.province){
            utils.getProvince(account.province.id);
            if(account.province.provinceId){
                utils.getCity(account.province.provinceId,account.city.id);
                utils.getArea(account.city.cityId,account.area.id);
            }
    	}else{
            utils.getProvince(null);
        }
        
        $('#userName').html(account.userName);
        $('#nickName').val(account.nickName);
    	$('#sex').html(account.sex==0?"男":"女");
        $("#birthDay").val(new Date(account.birthDay).pattern("yyyy-MM-dd HH:mm:ss"));
    	$('#mobileNo').val(account.mobileNo);
    },
    addProduct:function(createMode){
        $.ajax({
            type: "POST",
            url: config.baseURL + "product/"+createMode+".json",
            cache:false,
            dataType: "json",
            data : {
                        "id":$('#productId').val(),
                        "productName": $('#productName').val(),
                        "discountPrice" : $('#discountPrice').val(),
                        "originalPrice" : $('#originalPrice').val(),
                        "type" : $('#type').val(),
                        "hot" : $(':radio[name=hot]:checked').val(),
                        "stock" : $('#stock').val(),
                        "author" : $('#author').val(),
                        "publishingCompany" : $('#publishingCompany').val(),
                        "publishingDate" : $('#publishingDate').val(),
                        "imagePath" : $('#imagePath').val()
                    },
            success: function(data){
                if(data.result == 'success'){
                	$('#productListLink').click();
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>添加产品失败！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    recommendProducts:function(page){
        $.ajax({
            type: "GET",
            url: config.baseURL + "product/list.json",
            cache:false,
            dataType: "json",
            data : {"currentPage":page + 1,"perPageSize":customer.recommendProductsPerPageSize},
            success: function(data){
                if(data.result == 'success'){
                    $('#productList').html("");

                    $.each(data.productList, function(index, obj) {
                        var html = '<li><a href="'+config.baseURL+'product/'+obj.id+'"><img src="'+obj.imagePath+'"/>'+obj.productName+'</a></li>';
                            
                        $('#productList').append(html);
                    });
                    
                    $("#paginationDiv").pagination(data.productListCount, {
                        callback: customer.recommendProducts,//回调函数
                        num_display_entries: 5,
                        num_edge_entries: 3,
                        items_per_page:customer.recommendProductsPerPageSize,//每页显示多少条
                        current_page:page//当前页码
                    });
                    
                    customer.currentProductPageNo = page;
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>查询异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    searchProduct:function(page){
        $.ajax({
            type: "POST",
            url: config.baseURL + "product/searchProduct.json",
            cache:false,
            dataType: "json",
            data : {"currentPage":page + 1,"perPageSize":10,"keyword":customer.keyword},
            success: function(data){
                if(data.result == 'success'){
                    $('#searchList').html("");
                    
                    $.each(data.productList, function(index, obj) {
                    	var stock = '';
                        if(obj.stock<=0){
                            stock = '暂无';
                        }else if(obj.stock<=10){
                            stock = '货源紧张，欲购从速';
                        }else{
                            stock = '有货可至全国';
                        }
                    	
                        var html = '<li><a href="'+config.baseURL+'product/'+obj.id+'" class="productImg"><img src="'+config.baseURL+obj.imagePath+'"/></a>' +
                        		'<h4><a href="#" title="">'+obj.productName+'</a></h4><p>优惠价格：'+obj.discountPrice+'</p>' +
                        		'<p>库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存：'+stock+'</p>' +
                        		'</li>';
                            
                        $('#searchList').append(html);
                    });
                    
                    $("#paginationDiv").pagination(data.productListCount, {
                        callback: customer.searchProduct,//回调函数
                        num_display_entries: 5,
                        num_edge_entries: 3,
                        items_per_page:10,//每页显示多少条
                        current_page:page//当前页码
                    });
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>查询异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    productDetailInfo:function(productId){
       $.ajax({
            type: "GET",
            url: config.baseURL + "product/detail.json",
            cache:false,
            dataType: "json",
            data : {"id":productId},
            success: function(data){
                if(data.result == 'success'){
                    var obj = data.product;
                    $('#productImage').attr('src',config.baseURL + obj.imagePath);
                    $('#discountPrice').html(obj.discountPrice);
                    $('#discount').html(Math.floor(obj.discountPrice/obj.originalPrice*100)/10);
                    $('#originalPrice').html(obj.originalPrice);
                    $('#author').html(obj.author);
                    $('#publishingCompany').html(obj.publishingCompany);
                    $('#publishingDate').html(obj.publishingDate);

                    if(obj.stock<=0){
                        $('#stock').html('暂无');
                    }else if(obj.stock<=10){
                        $('#stock').html('货源紧张，欲购从速');
                    }else{
                        $('#stock').html('有货可至全国');
                    }
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>查询异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    addInShoppingCart:function(productId){
        if(productId == 0){
        	location.href = config.baseURL + "register.jsp";
        }else{
            $.ajax({
                type: "POST",
                url: config.baseURL + "shoppingCart/create.json",
                cache:false,
                dataType: "json",
                data : {"product.id":productId},
                success: function(data){
                    if(data.result == 'success'){
                        $.msgBox.window({
                            title:"提示",
                            msg : "<span>已成功放入购物车！</span>",
                            icon:"succeed",
                            time:1500,
                            width:250,
                            cls:'miniborder'
                        });
                    }else{
                        $.msgBox.window({
                            title:"提示",
                            msg : "<span>购物车放入失败，请稍候再试！</span>",
                            icon:"succeed",
                            time:1500,
                            width:250,
                            cls:'miniborder'
                        });
                    }
                }
            });
        }
    },
    getShoppingCartList:function(){
    	$.ajax({
            type: "GET",
            url: config.baseURL + "shoppingCart/list.json",
            cache:false,
            dataType: "json",
            success: function(data){
                if(data.result == 'success'){
                    $('#shoppingCartList').html("");

                    var totalPrice = 0;
                    
                    $.each(data.shoppingCartList, function(index, obj) {
                    	var product = obj.product;
                    	
                    	var price = obj.count*product.discountPrice;
                    	totalPrice = totalPrice + price;
                    	
                        var html = '<li><h3>店铺名称：xxx书店</h3>'+
                			'<span class="wrapChk"><input type="checkbox" value="'+obj.id+'" productId="'+product.id+'"/></span>'+
                			'<span class="wrapPro"><img src="'+config.baseURL+product.imagePath+'"/></span>'+
                			'<span class="wrapProName">'+
                				'<a href="'+config.baseURL+'product/'+product.id+'">'+product.productName+'</a><br />'+
                				'<a href="'+config.baseURL+'product/'+product.id+'">作者：'+product.author+'</a>'+
                			'</span>'+
                			'<span class="wrapPrice">'+product.originalPrice+'</span>'+
                			'<span class="wrapOnsale">'+product.discountPrice+'</span>'+
                			'<span class="wrapNum">'+
                				'<a href="javascript:void(0);" onclick="customer.changeCount('+obj.id+',-1,'+product.discountPrice+',\'click\');" class="add">'+
                					'<img src="'+config.baseURL+'style/images/redu.png"/>'+
                				'</a>'+
                				'<input type="text" id="productCount'+obj.id+'" value="'+obj.count+'" class="input_num" onblur="customer.changeCount('+obj.id+',+1,'+product.discountPrice+',\'input\');"/>'+
                				'<a href="javascript:void(0);" onclick="customer.changeCount('+obj.id+',+1,'+product.discountPrice+',\'click\');">'+
                					'<img src="'+config.baseURL+'style/images/plus.png"/>'+
                        		'</a>'+
                			'</span>'+
                			'<span class="wrap_priceTotle">￥<span content="productPrice" id="productPrice'+obj.id+'">'+price+'</span></span>'+
                			'<span class="wrap_delete"><a href="javascript:void(0);" onclick="customer.deleteShoppingCart('+obj.id+');" class="closeBtn"></a></span>'+
                		'</li>';
                            
                        $('#shoppingCartList').append(html);
                    });
                    
                    $('#totalPrice').html(totalPrice);
                    
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>查询异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    deleteShoppingCart:function(id){
        $.ajax({
            type: "POST",
            url: config.baseURL + "shoppingCart/delete.json",
            cache:false,
            dataType: "json",
            data : {"id":id},
            success: function(data){
                if(data.result == "success"){
                    customer.getShoppingCartList();
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>删除失败，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
       });
    },
    changeCount:function(id,num,discountPrice,mode){
    	var count = 0;
    	if(mode=="click"){
        	count = parseInt($('#productCount'+id).val()) + parseInt(num);
    	}else{
    		count = $('#productCount'+id).val();
    	}
    	if(count>0){
        	$('#productCount'+id).val(count);
        	$('#productPrice'+id).html(Math.round(count*discountPrice*100)/100);
        	
        	customer.countTotalPrice();
        	
        	customer.updateShoppingCartCount(id,count);
    	}
    },
    updateShoppingCartCount:function(id,count){
        $.ajax({
            type: "POST",
            url: config.baseURL + "shoppingCart/update.json",
            cache:false,
            dataType: "json",
            data : {"id":id,"count":count},
            success: function(data){
                if(data.result != "success"){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>更新购物车数量异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
       });
    },
    countTotalPrice:function(){
    	var totalPrice = "";
    	var priceSpan = $('#shoppingCartList').find("span[content='productPrice']");
    	$.each(priceSpan,function(i,e){
    		totalPrice += parseFloat(e.innerHTML).toFixed(2);
    	});
        $('#totalPrice').html(totalPrice);
    },
    orderList:function(page){
    	$.ajax({
            type: "GET",
            url: config.baseURL + "order/list.json",
            cache:false,
            dataType: "json",
            data : {"currentPage":page + 1,"perPageSize":10,"orderType":customer.currentOrderListOrderType},
            success: function(data){
                if(data.result == 'success'){
                    $('#orderList').html("");
        				
                    $.each(data.orderList, function(index, obj) {
                    	var status = obj.status==0?"未发货":"已发货";
                    	
                        var html = '<tr><td><a href="javascript:void(0);" class="order_num">'+obj.id+'</a></td>'+
                                '<td>'+obj.name+'</td><td>货到付款</td><td>￥'+obj.product.discountPrice*obj.count+'</td>'+
                                '<td>'+status+'</td><td>'+new Date(obj.createDate).pattern("yyyy-MM-dd")+'</td></tr>';
                            
                        $('#orderList').append(html);
                    });
                    
                    $("#paginationDiv").pagination(data.orderListCount, {
                        callback: customer.orderList,//回调函数
                        num_display_entries: 5,
                        num_edge_entries: 3,
                        items_per_page:10,//每页显示多少条
                        current_page:page//当前页码
                    });
                    
                    customer.currentOrderPageNo = page;
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>查询异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    changeOrderListOrderType:function(){
        if(customer.currentOrderListOrderType=="desc"){
            customer.currentOrderListOrderType = "asc";
        }else{
            customer.currentOrderListOrderType = "desc";
        }
        customer.orderList(0);
    },
    checkAllShoppingCart:function(){
    	var flag = $('#checkAll').attr("checked");
    	if(flag == 'checked'){
    	   $("input[type='checkbox']").attr('checked', true);
    	}else{
    	   $("input[type='checkbox']").attr('checked', false);
    	}
    },
    goToCreateOrder:function(){
    	var param = "{";
    	$("#shoppingCartList input[type='checkbox']").each(function(i) {
            var id = $(this).val();
            if($(this).attr('checked') && id && id != 'on') {
            	param += "'shoppingCartIdList["+i+"]':"+id+",'orderList["+i+"].product.id':"+$(this).attr('productId')+
            	       ",'orderList["+i+"].count':"+$('#productCount'+id).val()+",";
            }
        });
        param = param.substring(0,param.length-1);
        param += "}";
        
        if(param.length>2){
            $.ajax({
                type: "POST",
                url: config.baseURL + "order/create.json",
                cache:false,
                dataType: "json",
                data : eval('('+param+')'),
                success: function(data){
                    if(data.result == "success"){
                        $.msgBox.window({
                            title:"提示",
                            msg : "<span>创建订单成功！</span>",
                            icon:"succeed",
                            time:1500,
                            width:250,
                            cls:'miniborder'
                        });
                    	customer.getShoppingCartList();
                    }else{
                    	if(data.errorCode == "addressInfoNull"){
                            $.msgBox.window({
                                title:"提示",
                                msg : "<span>请先完善我的地址！</span>",
                                icon:"succeed",
                                time:1500,
                                width:250,
                                cls:'miniborder'
                            });
                    	}else{
                            $.msgBox.window({
                                title:"提示",
                                msg : "<span>创建订单异常，请稍候再试！</span>",
                                icon:"succeed",
                                time:1500,
                                width:250,
                                cls:'miniborder'
                            });
                    	}
                    }
                }
            });
        }else{
            $.msgBox.window({
                title:"提示",
                msg : "<span>请至少选择购物车中的一项去结算！</span>",
                icon:"succeed",
                time:1500,
                width:270,
                cls:'miniborder'
            });
        }
    },
    getAddress:function(){
        $.ajax({
            type: "GET",
            url: config.baseURL + "address/detail.json",
            cache:false,
            dataType: "json",
            success: function(data){
                if(data.result == "success"){
                	var address = data.address;
                	if(address.tel){
                    	var tel = address.tel;
                    	var telArray = tel.split("-");
                        $("#zoneNo").val(telArray[0]?telArray[0]:"");
                        $("#telNo").val(telArray[1]?telArray[1]:"");
                        $("#extensionNo").val(telArray[2]?telArray[2]:"");
                	}
                	if(address.province){
                        utils.getProvince(address.province.id);
                        if(address.province.provinceId){
                            utils.getCity(address.province.provinceId,address.city.id);
                            utils.getArea(address.city.cityId,address.area.id);
                        }
                	}else{
                        utils.getProvince(null);
                    }
                	
                    $("#id").val(address.id);
                    $("#name").val(address.name);
                    $("#road").val(address.road);
                    $("#postCode").val(address.postCode);
                    $("#tel").val(tel);
                    $("#mobile").val(address.mobile);
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>地址获取异常，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        });
    },
    initAddressForm:function(){
        var options = {
            dataType : 'json',
            beforeSerialize : function(form, options) {
                var zoneNo = $("#zoneNo").val();
                var telNo = $("#telNo").val();
                var extensionNo= $("#extensionNo").val();
                $('#tel').val(zoneNo+"-"+telNo+"-"+extensionNo);
                
                options.url = config.baseURL + 'address/update.json';
            },
            beforeSubmit : function() {
                if(!$('#name').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入收件人姓名！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if($('#province').val()==0){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请选择省份！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if($('#city').val()==0){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请选择城市！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if($('#area').val()==0){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请选择地区！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#road').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入街道地址！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#postCode').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入邮政编码！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#zoneNo').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入固定电话区号！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#telNo').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入固定电话号码！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#mobileNo').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入手机号码！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                $('#addressForm').attr('action',config.baseURL + 'address/update.json');
                return true;
            },
            success : function(data) {
                if(data.result=='success'){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>资料更新成功！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>资料更新失败，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        };
        
        $('#addressForm').submit(function() {
            $(this).ajaxSubmit(options);
            return false;
        });
    },
    initUserInfoForm:function(){
        var options = {
            dataType : 'json',
            beforeSerialize : function(form, options) {
                var zoneNo = $("#zoneNo").val();
                var telNo = $("#telNo").val();
                var extensionNo= $("#extensionNo").val();
                $('#tel').val(zoneNo+"-"+telNo+"-"+extensionNo);
                
                options.url = config.baseURL + 'account/update.json';
            },
            beforeSubmit : function() {
                if(!$('#nickName').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入昵称！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#birthDay').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入生日！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if($('#province').val()==0){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请选择省份！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if($('#city').val()==0){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请选择城市！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if($('#area').val()==0){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请选择地区！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#zoneNo').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入固定电话区号！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#telNo').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入固定电话号码！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                if(!$('#mobileNo').val()){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>请输入手机号码！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                    return false;
                }
                $('#userInfoForm').attr('action',config.baseURL + 'account/update.json');
                return true;
            },
            success : function(data) {
                if(data.result=='success'){
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>资料更新成功！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }else{
                    $.msgBox.window({
                        title:"提示",
                        msg : "<span>资料更新失败，请稍候再试！</span>",
                        icon:"succeed",
                        time:1500,
                        width:250,
                        cls:'miniborder'
                    });
                }
            }
        };
        
        $('#userInfoForm').submit(function() {
            $(this).ajaxSubmit(options);
            return false;
        });
    }
};